import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hongsheng/app/SPClassApplicaion.dart';
import 'package:hongsheng/model/SPClassAnylizeMatchList.dart';
import 'package:hongsheng/model/SPClassBaseModelEntity.dart';
import 'package:hongsheng/model/SPClassChartDoughnutData.dart';
import 'package:hongsheng/model/SPClassForecast.dart';
import 'package:hongsheng/model/SPClassGuessMatchInfo.dart';
import 'package:hongsheng/pages/dialogs/SPClassForcecastRuluDialog.dart';
import 'package:hongsheng/utils/SPClassCommonMethods.dart';
import 'package:hongsheng/utils/SPClassDateUtils.dart';
import 'package:hongsheng/utils/SPClassListUtil.dart';
import 'package:hongsheng/api/SPClassApiManager.dart';
import 'package:hongsheng/api/SPClassHttpCallBack.dart';
import 'package:hongsheng/utils/SPClassStringUtils.dart';
import 'package:hongsheng/pages/common/SPClassLoadingPage.dart';
import 'package:hongsheng/pages/common/SPClassNoDataView.dart';
import 'package:hongsheng/utils/SPClassImageUtil.dart';
import 'package:hongsheng/utils/colors.dart';
import 'package:sprintf/sprintf.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

///新的比赛分析详情页
class SPClassMatchAnalysis extends StatefulWidget{
  Map<String,dynamic> params;
  String type;
  SPClassGuessMatchInfo spProGuessMatch;
  SPClassMatchAnalysis(this.params,this.spProGuessMatch,{this.type="足球"});

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return SPClassMatchAnalysisState();
  }

}

class SPClassMatchAnalysisState extends State<SPClassMatchAnalysis> with AutomaticKeepAliveClientMixin,TickerProviderStateMixin{
  SPClassAnylizeMatchList ?spProAnylizeMatchList;
  int spProHistoryIndex=0;
  int spProHistoryOneIndex=0;
  int spProHistoryTwoIndex=0;

  var spProPointsKey="总";
  List<SPClassTeamPointsList> spProTeamPointsList=[];//积分排名

  var spProHistoryKey="全部";
  List<SPClassEntityHistory> spProHistoryList= [];//对赛往绩

  var spProHistoryOneKey="全部";
  List<SPClassEntityHistory> spProHistoryOne= [];//近期战绩

  var spProHistoryTwoKey="全部";
  List<SPClassEntityHistory> spProHistoryTwo= [];//近期战绩 客队


  List<SPClassEntityHistory> spProFutureListOne=[];//未来赛事
  List<SPClassEntityHistory> spProFutureListTwo=[];//未来赛事


  var spProIsLoading=true;

  SPClassForecast ?spProForecastInfo;

  bool isShowjifen = true;
  bool isShowHistory = true;
  bool isShowjinqiOne = true;
  bool isShowjinqiTwo = true;
  bool isShowFuture = true;

  bool isShowMorejifen = false;
  bool isShowMoreHistory = false;
  bool isShowMorejinqiOne = false;
  bool isShowMorejinqiTwo = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    SPClassApiManager().spFunMatchAnalyse(queryParameters: widget.params,spProCallBack: SPClassHttpCallBack<SPClassAnylizeMatchList>(
        spProOnSuccess: (list){
          spProAnylizeMatchList=list;
          spProIsLoading=false;
          if(spProAnylizeMatchList!=null){

            spFunInitPointData();
            if(spProAnylizeMatchList?.history!=null&&spProAnylizeMatchList!.history!.isNotEmpty){
              spProHistoryList.clear();
              spProHistoryList.addAll(spProAnylizeMatchList!.history!);
            }
            if(spProAnylizeMatchList?.spProTeamOneHistory!=null&&spProAnylizeMatchList!.spProTeamOneHistory!.isNotEmpty){
              spProHistoryOne.addAll(spProAnylizeMatchList!.spProTeamOneHistory!);
            }
            if(spProAnylizeMatchList!.spProTeamTwoHistory!=null&&spProAnylizeMatchList!.spProTeamTwoHistory!.isNotEmpty){
              spProHistoryTwo.addAll(spProAnylizeMatchList!.spProTeamTwoHistory!);
            }
            spFunInitFutureList();
          }


          setState(() {
          });

        },
        onError: (e){
          spProIsLoading=false;
          setState(() {
          });
        }
    ));

    //   getForecastInfo();
  }

  @override
  Widget build(BuildContext context) {


    // TODO: implement build
    super.build(context);
    return Visibility(
      child: SingleChildScrollView(
        child: Column(
          children: [

            SizedBox(height:width(10)),

            Visibility(
              child: Stack(
                alignment:Alignment.topCenter,
                children: <Widget>[
                  Container(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      boxShadow:[
                        BoxShadow(
                          offset: Offset(2,5),
                          color: Color(0x0C000000),
                          blurRadius:width(6,),),
                        BoxShadow(
                          offset: Offset(-5,1),
                          color: Color(0x0C000000),
                          blurRadius:width(6,),
                        )
                      ],
                      borderRadius: BorderRadius.circular(width(7)),
                    ),
                    margin: EdgeInsets.only(left: width(10),right: width(10),top: width(10)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        SizedBox(height: width(30),),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: <Widget>[
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Text(spFunGetSupportRate(1),style: TextStyle(fontSize: sp(10)),),
                                SizedBox(height: width(5),),
                                AnimatedSize(
                                  vsync: this,
                                  duration: Duration(
                                      milliseconds: 300
                                  ),
                                  child: Container(
                                    width: width(27),
                                    height: spFunGetForecastHeight(1),
                                    decoration: BoxDecoration(
                                        gradient: LinearGradient(
                                            begin: Alignment.topCenter,
                                            end: Alignment.bottomCenter,
                                            stops: [spFunGetUserSupport(1),0.0],
                                            colors: [
                                              Color(0xFFF14B0B),
                                              Color(0xFFF1150B),
                                            ]
                                        )
                                    ),
                                  ),
                                ),
                                SizedBox(height: width(5),),
                                Text("主胜",style: TextStyle(fontSize: sp(12)),),

                                GestureDetector(
                                  child: Container(
                                    decoration: (spProForecastInfo!=null
                                        &&spProForecastInfo?.spProSupportWhich!=null
                                        &&spProForecastInfo?.spProSupportWhich=="1"
                                    )?BoxDecoration(
                                        boxShadow: [
                                          BoxShadow(
                                              color: Color(0x66FF9613).withOpacity(0.1),
                                              offset: Offset(5,1),
                                              blurRadius: width(10)
                                          )
                                        ]
                                    ):null,
                                    padding: EdgeInsets.all(width(8)),
                                    child: Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(
                                          (spProForecastInfo!=null
                                              &&spProForecastInfo?.spProSupportWhich!=null
                                              &&spProForecastInfo?.spProSupportWhich=="1"
                                          )?
                                          "ic_forecast_gooded":"ic_forecast_good"),
                                      width: width(16),
                                    ),
                                  ),
                                  onTap: (){
                                    spFunSupportForecast("1");
                                  },
                                )
                              ],
                            ),

                            SizedBox(width: width(67),),

                            Column(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Text(spFunGetSupportRate(0),style: TextStyle(fontSize: sp(10)),),
                                SizedBox(height: width(5),),
                                AnimatedSize(
                                  vsync: this,
                                  duration: Duration(
                                      milliseconds: 300
                                  ),
                                  child: Container(
                                    width: width(27),
                                    height: spFunGetForecastHeight(0),
                                    decoration: BoxDecoration(
                                        gradient: LinearGradient(
                                            begin: Alignment.topCenter,
                                            end: Alignment.bottomCenter,
                                            stops: [spFunGetUserSupport(0),0.0],
                                            colors: [
                                              Color(0xFFB1B1B1),
                                              Color(0x91030000),

                                            ]
                                        )
                                    ),
                                  ),
                                ),
                                SizedBox(height: width(5),),
                                Text("平局",style: TextStyle(fontSize: sp(12)),),

                                GestureDetector(
                                  child: Container(
                                    decoration: (spProForecastInfo!=null
                                        &&spProForecastInfo?.spProSupportWhich!=null
                                        &&spProForecastInfo?.spProSupportWhich=="0"
                                    )?BoxDecoration(
                                        boxShadow: [
                                          BoxShadow(
                                              color: Color(0x66FF9613).withOpacity(0.1),
                                              offset: Offset(5,1),
                                              blurRadius: width(10)
                                          )
                                        ]
                                    ):null,
                                    padding: EdgeInsets.all(width(8)),
                                    child: Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(
                                          (spProForecastInfo!=null
                                              &&spProForecastInfo?.spProSupportWhich!=null
                                              &&spProForecastInfo?.spProSupportWhich=="0"
                                          )?
                                          "ic_forecast_gooded":"ic_forecast_good"),
                                      width: width(16),
                                    ),
                                  ),
                                  onTap: (){
                                    spFunSupportForecast("0");
                                  },
                                )
                              ],
                            ),

                            SizedBox(width: width(67),),

                            Column(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Text(spFunGetSupportRate(2),style: TextStyle(fontSize: sp(10)),),
                                SizedBox(height: width(5),),
                                AnimatedSize(
                                  vsync: this,
                                  duration: Duration(
                                      milliseconds: 300
                                  ),
                                  child: Container(
                                    width: width(27),
                                    height: spFunGetForecastHeight(2),
                                    decoration: BoxDecoration(
                                        gradient: LinearGradient(
                                            begin: Alignment.topCenter,
                                            end: Alignment.bottomCenter,
                                            stops: [spFunGetUserSupport(2),0.0],
                                            colors: [
                                              Color(0xFF2CDDFF),
                                              Color(0xFF1489FA),

                                            ]
                                        )
                                    ),
                                  ),
                                ),
                                SizedBox(height: width(5),),
                                Text("客胜",style: TextStyle(fontSize: sp(12)),),

                                GestureDetector(
                                  child: Container(
                                    decoration: (spProForecastInfo!=null
                                        &&spProForecastInfo?.spProSupportWhich!=null
                                        &&spProForecastInfo?.spProSupportWhich=="2"
                                    )?BoxDecoration(
                                        boxShadow: [
                                          BoxShadow(
                                              color: Color(0x66FF9613).withOpacity(0.1),
                                              offset: Offset(5,1),
                                              blurRadius: width(10)
                                          )
                                        ]
                                    ):null,
                                    padding: EdgeInsets.all(width(8)),
                                    child: Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(
                                          (spProForecastInfo!=null
                                              &&spProForecastInfo?.spProSupportWhich!=null
                                              &&spProForecastInfo?.spProSupportWhich=="2"
                                          )?
                                          "ic_forecast_gooded":"ic_forecast_good"),
                                      width: width(16),
                                    ),
                                  ),
                                  onTap: (){
                                    spFunSupportForecast("2");
                                  },
                                )
                              ],
                            ),
                          ],
                        ),
                        SizedBox(height: width(10),),

                      ],

                    ),
                  ),
                  Positioned(
                    top: width(10),
                    child: Stack(
                      alignment: Alignment.topCenter,
                      children: <Widget>[
                        Image.asset(
                          SPClassImageUtil.spFunGetImagePath("bg_title_forecast"),
                          width: width(124),
                        ),
                        Text("全民预测",style: TextStyle(color: Colors.white,fontSize: sp(16),fontWeight: FontWeight.bold),),
                      ],
                    ),
                  ),

                  Positioned(
                    top: width(15),
                    right: width(25),
                    child:  GestureDetector(
                      child: Row(
                        children: <Widget>[
                          Container(
                            alignment: Alignment.center,
                            child: Text("?",style: TextStyle(color: Colors.white,fontSize: sp(8)),),
                            width: width(16),
                            height: width(16),
                            decoration: BoxDecoration(
                                color: Color(0xFFB5B5B5),
                                shape: BoxShape.circle
                            ),
                          ),
                        ],
                      ),
                      onTap: (){
                        showDialog(context: context, builder: (c)=>SPClassForcecastRuluDialog());
                      },
                    ),
                  )

                ],
              ),
              visible: (spProForecastInfo!=null),
            ),

            Visibility(
              child: SPClassNoDataView(height:width(400),),
              visible:(SPClassListUtil.spFunIsEmpty(spProTeamPointsList)
                  && SPClassListUtil.spFunIsEmpty(spProHistoryList)
                  && SPClassListUtil.spFunIsEmpty(spProHistoryOne)
                  && SPClassListUtil.spFunIsEmpty(spProHistoryTwo)
                  && SPClassListUtil.spFunIsEmpty(spProFutureListOne)
                  && SPClassListUtil.spFunIsEmpty(spProFutureListTwo)
                  && SPClassListUtil.spFunIsEmpty(spProFutureListTwo)
                  && (spProForecastInfo==null)
              ),
            ),
            ///积分排名
            Visibility(
              child: AnimatedSize(
                vsync: this,
                duration: Duration(
                    milliseconds: 300
                ),
                child:Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      boxShadow:[
                        BoxShadow(
                          offset: Offset(0,0),
                          color: Color(0xFF000000).withOpacity(0.15),
                          blurRadius:width(6,),),
                      ],
                      borderRadius: BorderRadius.circular(4)
                  ),
                  margin: EdgeInsets.only(left: width(10),right: width(10),top: width(10)),
                  child: Column(
                    children: <Widget>[
                      Container(
                        height:width(28),
                        padding: EdgeInsets.only(left: width(14),right: width(10)),
                        decoration: BoxDecoration(
                            color: Color(0xFFF2F2F2),
                            borderRadius: BorderRadius.vertical(top: Radius.circular(4)),
                        ),
                        child: Row(
                          children: <Widget>[
                            Container(
                              width: height(4),
                              height: height(14),
                              decoration: BoxDecoration(
                                  color: Color(0xFFDE3C31),
                                  borderRadius: BorderRadius.circular(100)
                              ),
                            ),
                            SizedBox(width: 4,),
                            Text("积分排名",style: TextStyle(fontWeight: FontWeight.w600,fontSize: sp(15)),),
                            Expanded(child: SizedBox(),),
                            GestureDetector(
                              behavior: HitTestBehavior.opaque,
                              child: Container(
                                padding: EdgeInsets.all(width(7)),
                                child: Image.asset(SPClassImageUtil.spFunGetImagePath(isShowjifen?"ic_down_arrow":"ic_up_arrow"),
                                  width: width(11),
                                ),
                              ),
                              onTap: (){
                                isShowjifen =!isShowjifen;
                                setState(() {

                                });
                              },
                            )

                          ],
                        ),
                      ),
                      Visibility(
                        visible: isShowjifen,
                        child: Column(
                          children: <Widget>[
                            Container(
                              child: Row(
                                children: <Widget>[
                                  SizedBox(width: width(14),),
                                  ClipRRect(
                                    borderRadius: BorderRadius.circular(500),
                                    child:SPClassImageUtil.spFunNetWordImage(
                                        placeholder: "ic_team_one",
                                        url: widget.spProGuessMatch.spProIconUrlOne??'',
                                        width: width(12),
                                        height:  width(12)),
                                  ),
                                  Text("${widget.spProGuessMatch.spProTeamOne}",style: TextStyle(color: MyColors.main1,fontSize: sp(11)),),
                                ],
                              ),
                            ),
                            jifenItem(team: 1),
                            Container(
                              child: Row(
                                children: <Widget>[
                                  SizedBox(width: width(14),),
                                  ClipRRect(
                                    borderRadius: BorderRadius.circular(500),
                                    child:SPClassImageUtil.spFunNetWordImage(
                                        placeholder: "ic_team_two",
                                        url: widget.spProGuessMatch.spProIconUrlTwo??'',
                                        width: width(12),
                                        height:  width(12)),
                                  ),
                                  Text("${widget.spProGuessMatch.spProTeamTwo}",style: TextStyle(color: MyColors.main1,fontSize: sp(11)),),
                                ],
                              ),
                            ),
                            jifenItem(team: 0),
                            SizedBox(height: width(14),),
                            Container(
                              child: Column(
                                children: <Widget>[
                                  (spFunGetMatchAllPointsScore(1,"全部")+spFunGetMatchAllPointsScore(2,"全部")==0) ?SizedBox():Container(
                                    child: Column(
                                      children: <Widget>[
                                        Row(
                                          mainAxisAlignment:MainAxisAlignment.spaceBetween,
                                          children: <Widget>[
                                            Container(
                                              child: Text(sprintf("%d胜%d平%d负",
                                                  [
                                                    spFunGetMatchCount(spFunGetHistoryOneList("全部").take(spFunGetMinListLength("全部")).toList(), 1),
                                                    spFunGetMatchCount(spFunGetHistoryOneList("全部").take(spFunGetMinListLength("全部")).toList(), 0),
                                                    spFunGetMatchCount(spFunGetHistoryOneList("全部").take(spFunGetMinListLength("全部")).toList(), 2),
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),
                                            Text("近期战绩",
                                              style: TextStyle(fontSize: sp(12),color: MyColors.grey_99),),
                                            Container(
                                              child: Text(sprintf("%d胜%d平%d负",
                                                  [
                                                    spFunGetMatchCount(spFunGetHistoryTwoList("全部").take(spFunGetMinListLength("全部")).toList(), 1,winTeam: 2),
                                                    spFunGetMatchCount(spFunGetHistoryTwoList("全部").take(spFunGetMinListLength("全部")).toList(), 0,winTeam: 2),
                                                    spFunGetMatchCount(spFunGetHistoryTwoList("全部").take(spFunGetMinListLength("全部")).toList(), 2,winTeam: 2),
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),
                                          ],
                                        ),
                                        Row(
                                          children: <Widget>[
                                            Expanded(
                                              child:  Row(
                                                children: <Widget>[
                                                  Expanded(
                                                    flex:(spFunGetMatchAllPointsScore(1,"全部") *100).toInt(),
                                                    child: Container(
                                                      margin: EdgeInsets.only(right: 2),
                                                      alignment: Alignment.center,
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFFDE3C31),
                                                          borderRadius: BorderRadius.horizontal(left:Radius.circular(300) )
                                                      ),
                                                      height: width(7),
                                                    ),
                                                  ),
                                                  Expanded(
                                                    flex:(spFunGetMatchAllPointsScore(2,"全部") *100).toInt() ,
                                                    child: Container(
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFF5D8AF7),
                                                          borderRadius: BorderRadius.horizontal(right:Radius.circular(300) )
                                                      ),
                                                      alignment: Alignment.center,
                                                      height: width(7),
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ) ,
                                          ],
                                        ),
                                        SizedBox(height: width(7),),
                                      ],
                                    ),
                                  ),
                                  (spFunGetHistoryOneList("同主客").take(spFunGetMinListLength("同主客")).toList().length==0)? SizedBox(): Container(
                                    child: Column(
                                      children: <Widget>[
                                        Row(
                                          mainAxisAlignment:MainAxisAlignment.spaceBetween,
                                          children: <Widget>[
                                            Container(
                                              child: Text(sprintf("%d胜%d平%d负",
                                                  [
                                                    spFunGetMatchCount(spFunGetHistoryOneList("同主客").take(spFunGetMinListLength("同主客")).toList(), 1),
                                                    spFunGetMatchCount(spFunGetHistoryOneList("同主客").take(spFunGetMinListLength("同主客")).toList(), 0),
                                                    spFunGetMatchCount(spFunGetHistoryOneList("同主客").take(spFunGetMinListLength("同主客")).toList(), 2),
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),
                                            Text("同主客战绩",
                                              style: TextStyle(fontSize: sp(12),color: MyColors.grey_99),),
                                            Container(
                                              child: Text(sprintf("%d胜%d平%d负",
                                                  [
                                                    spFunGetMatchCount(spFunGetHistoryTwoList("同主客").take(spFunGetMinListLength("同主客")).toList(), 1,winTeam: 2),
                                                    spFunGetMatchCount(spFunGetHistoryTwoList("同主客").take(spFunGetMinListLength("同主客")).toList(), 0,winTeam: 2),
                                                    spFunGetMatchCount(spFunGetHistoryTwoList("同主客").take(spFunGetMinListLength("同主客")).toList(), 2,winTeam: 2),
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),

                                          ],
                                        ),
                                        Row(
                                          children: <Widget>[
                                            Expanded(
                                              child:  Row(
                                                children: <Widget>[
                                                  Expanded(
                                                    flex:(spFunGetMatchAllPointsScore(1,"同主客")*100).toInt(),
                                                    child: Container(
                                                      margin: EdgeInsets.only(right: 2),
                                                      alignment: Alignment.center,
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFFDE3C31),
                                                          borderRadius: BorderRadius.horizontal(left:Radius.circular(300) )
                                                      ),
                                                      height: width(7),
                                                    ),
                                                  ),
                                                  Expanded(
                                                    flex:(spFunGetMatchAllPointsScore(2,"同主客")*100).toInt(),
                                                    child: Container(
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFF5D8AF7),
                                                          borderRadius: BorderRadius.horizontal(right:Radius.circular(300) )
                                                      ),
                                                      alignment: Alignment.center,
                                                      height: width(7),
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ) ,
                                          ],
                                        ),
                                        SizedBox(height: width(7),),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Column(
                                      children: <Widget>[
                                        Row(
                                          mainAxisAlignment:MainAxisAlignment.spaceBetween,
                                          children: <Widget>[
                                            Container(
                                              child: Text(sprintf("%s",
                                                  [
                                                    SPClassStringUtils.spFunSqlitZero(spFunAvgWinOrLoseScoreOne(true).toStringAsFixed(2))
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),
                                            Text("场均进球",
                                              style: TextStyle(fontSize: sp(12),color: MyColors.grey_99),),
                                            Container(
                                              child: Text(sprintf("%s",
                                                  [

                                                    SPClassStringUtils.spFunSqlitZero( spFunAvgWinOrLoseScoreTwo(true).toStringAsFixed(2))

                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),

                                          ],
                                        ),
                                        Row(
                                          children: <Widget>[
                                            Expanded(
                                              child:  Row(
                                                children: <Widget>[
                                                  Expanded(
                                                    flex:(spFunAvgWinOrLoseScoreOne(true)*100).toInt() ,

                                                    child: Container(
                                                      margin: EdgeInsets.only(right: 2),
                                                      alignment: Alignment.center,
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFFDE3C31),
                                                          borderRadius: BorderRadius.horizontal(left:Radius.circular(300) )
                                                      ),
                                                      height: width(7),
                                                    ),
                                                  ),
                                                  Expanded(
                                                    flex:(spFunAvgWinOrLoseScoreTwo(true)*100).toInt() ,
                                                    child: Container(
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFF5D8AF7),
                                                          borderRadius: BorderRadius.horizontal(right:Radius.circular(300) )
                                                      ),
                                                      alignment: Alignment.center,
                                                      height: width(7),
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ) ,
                                          ],
                                        ),
                                        SizedBox(height: width(7),),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Column(
                                      children: <Widget>[
                                        Row(
                                          mainAxisAlignment:MainAxisAlignment.spaceBetween,
                                          children: <Widget>[
                                            Container(
                                              child: Text(sprintf("%s",
                                                  [
                                                    SPClassStringUtils.spFunSqlitZero(spFunAvgWinOrLoseScoreOne(false).toStringAsFixed(2))
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),
                                            Text("场均失球",
                                              style: TextStyle(fontSize: sp(12),color: MyColors.grey_99),),
                                            Container(
                                              child: Text(sprintf("%s",
                                                  [
                                                    SPClassStringUtils.spFunSqlitZero(spFunAvgWinOrLoseScoreTwo(false).toStringAsFixed(2))
                                                  ]
                                              ),
                                                style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),
                                              ),
                                            ),
                                          ],
                                        ),
                                        Row(
                                          children: <Widget>[
                                            Expanded(
                                              child:  Row(
                                                children: <Widget>[
                                                  Expanded(
                                                    flex:(spFunAvgWinOrLoseScoreTwo(false)*100).toInt() ,
                                                    child: Container(
                                                      margin: EdgeInsets.only(right: 2),
                                                      alignment: Alignment.center,
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFFDE3C31),
                                                          borderRadius: BorderRadius.horizontal(left:Radius.circular(300) )
                                                      ),
                                                      height: width(7),
                                                    ),
                                                  ),
                                                  Expanded(
                                                    flex:(spFunAvgWinOrLoseScoreOne(false)*100).toInt() ,
                                                    child: Container(
                                                      decoration: BoxDecoration(
                                                          color: Color(0xFF5D8AF7),
                                                          borderRadius: BorderRadius.horizontal(right:Radius.circular(300) )
                                                      ),
                                                      alignment: Alignment.center,
                                                      height: width(7),
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ) ,
                                          ],
                                        ),
                                        SizedBox(height: width(7),),
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                              margin: EdgeInsets.symmetric(horizontal: width(20)),
                            ),
                            SizedBox(height: width(10),),

                          ],
                        ),
                      )
                    ],
                  ),
                ) ,
              ),
              visible:SPClassListUtil.spFunIsNotEmpty(spProTeamPointsList) ,
            ),
            ///对赛往绩
            Visibility(
              child: Container(
                decoration: BoxDecoration(
                    color: Colors.white,
                    boxShadow:[
                      BoxShadow(
                        offset: Offset(0,0),
                        color: Color(0xFF000000).withOpacity(0.15),
                        blurRadius:width(6,),),
                    ],
                    borderRadius: BorderRadius.circular(4)
                ),
                margin: EdgeInsets.only(left: width(10),right: width(10),top: width(10)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      height:width(28),
                      padding: EdgeInsets.only(left: width(14),right: width(10)),
                      decoration: BoxDecoration(
                        color: Color(0xFFF2F2F2),
                        borderRadius: BorderRadius.vertical(top: Radius.circular(4)),
                      ),
                      child: Row(
                        children: <Widget>[
                          Container(
                            width: height(4),
                            height: height(14),
                            decoration: BoxDecoration(
                                color: Color(0xFFDE3C31),
                                borderRadius: BorderRadius.circular(100)
                            ),
                          ),
                          SizedBox(width: 4,),
                          Text("对赛往绩",style: TextStyle(fontWeight: FontWeight.w600,fontSize: sp(15)),),
                          Expanded(child: SizedBox(),),
                          GestureDetector(
                            onTap:(){
                              spProHistoryKey="全部";
                              setState(() {
                              });
                            },
                            child: Row(
                                children: <Widget>[
                                  Image.asset(
                                    SPClassImageUtil.spFunGetImagePath(spProHistoryKey=="全部"?"ic_selected":"ic_select_un",),
                                    width: width(13),
                                  ),
                                  SizedBox(width: width(4),),
                                  Text("全部",style: TextStyle(fontSize: sp(11),color:MyColors.grey_33),)
                                ],
                            ),
                          ),
                          SizedBox(width: width(10),),
                          GestureDetector(
                            onTap:(){
                              spProHistoryKey="主场";
                              setState(() {
                              });
                            },
                            child: Row(
                              children: <Widget>[
                                Image.asset(
                                  SPClassImageUtil.spFunGetImagePath(spProHistoryKey=="主场"?"ic_selected":"ic_select_un",),
                                  width: width(13),
                                ),
                                SizedBox(width: width(4),),
                                Text("同主客",style: TextStyle(fontSize: sp(11),color:MyColors.grey_33),)
                              ],
                            ),
                          ),
                          SizedBox(width: width(14),),
                          GestureDetector(
                            onTap:(){
                              isShowMoreHistory=false;
                              setState(() {

                              });
                            },
                            child: Container(
                              height:width(18),
                              width:width(42),
                              decoration: BoxDecoration(
                                  borderRadius: BorderRadius.only(
                                      bottomLeft:Radius.circular(width(2)),
                                      topLeft: Radius.circular(width(2))),
                                  border: Border.all(color: !isShowMoreHistory? Color(0xFFDE3C31):Color(0xFFC4C4C4),width: 0.4),
                                  color: !isShowMoreHistory? Color(0xFFDE3C31):Colors.white
                              ),
                              alignment: Alignment.center,
                              child: Text("近10场",style: TextStyle(fontSize: sp(11),color:!isShowMoreHistory?Colors.white:MyColors.main1 ),),
                            ),
                          ),
                          GestureDetector(
                            onTap:(){
                              isShowMoreHistory=true;
                              setState(() {

                              });
                            },
                            child: Container(
                                height:width(18),
                              width:width(42),
                              decoration: BoxDecoration(
                                  borderRadius: BorderRadius.only(
                                      bottomRight:Radius.circular(width(2)),
                                      topRight: Radius.circular(width(2))),
                                  border: Border.all(color: isShowMoreHistory? Color(0xFFDE3C31):Color(0xFFC4C4C4),width: 0.4),
                                  color: isShowMoreHistory? Color(0xFFDE3C31):Colors.white
                              ),
                              alignment: Alignment.center,
                              child: Text("近20场",style: TextStyle(fontSize: sp(11),color:isShowMoreHistory?Colors.white:MyColors.main1 ),),
                            ),
                          ),
                          GestureDetector(
                            behavior: HitTestBehavior.opaque,
                            child: Container(
                              padding: EdgeInsets.all(width(7)),
                              child: Image.asset(SPClassImageUtil.spFunGetImagePath(isShowHistory?"ic_down_arrow":"ic_up_arrow"),
                                width: width(11),
                              ),
                            ),
                            onTap: (){
                              isShowHistory =!isShowHistory;
                              setState(() {

                              });
                            },
                          )

                        ],
                      ),
                    ),
                    Visibility(
                        visible: isShowHistory,
                        child: Column(
                            children: <Widget>[
                              SizedBox(height:width(10) ,),
                              Container(
                                margin: EdgeInsets.symmetric(horizontal:  height(11)),
                                child:  Column(
                                  children: <Widget>[
                                    Row(
                                      children: <Widget>[
                                        Text(widget.spProGuessMatch.spProTeamOne??'',
                                          style: TextStyle(
                                            fontSize: sp(11),
                                            color: Color(0xFFDE3C31),
                                          ),),
                                        Text(sprintf("  %d胜%d平%d负",[
                                          spFunGetMatchCount(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),1),
                                          spFunGetMatchCount(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),0),
                                          spFunGetMatchCount(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),2),
                                        ]
                                        ),

                                          style: TextStyle(fontSize: sp(11)),),
                                      ],
                                    ),
                                    SizedBox(height:3),
                                    Row(
                                      children: <Widget>[
                                        spFunGetMatchRate(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),1)==0? SizedBox(): Container(
                                          margin: EdgeInsets.only(right: 2),
                                          alignment: Alignment.center,
                                          width: width(318)*spFunGetMatchRate(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),1),
                                          height: width(4),
                                          color: Color(0xFFDE3C31),
                                        ),

                                        spFunGetMatchRate(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),0)==0? SizedBox(): Container(
                                          margin: EdgeInsets.only(right: 2),
                                          alignment: Alignment.center,
                                          width: width(318)*spFunGetMatchRate(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),0),
                                          height: width(4),
                                          color: Colors.blue,
                                        ),

                                        spFunGetMatchRate(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),2)==0? SizedBox(): Expanded(
                                          child: Container(
                                            alignment: Alignment.center,
                                            width: width(318)*spFunGetMatchRate(getNearData(spFunGetHistoryList(spProHistoryKey),isShowMoreHistory),2),
                                            height: width(4),
                                            color: Color(0xFF5FB349),
                                          ),
                                        ),

                                      ],
                                    )
                                  ],
                                ),
                              ),
                              Container(
                                margin: EdgeInsets.symmetric(
                                    horizontal:  height(11),
                                    vertical:height(8) ),
                                child:  Column(
                                  children: <Widget>[
                                    Row(
                                      children: <Widget>[
                                        Text(widget.spProGuessMatch.spProTeamOne??'',
                                          style: TextStyle(
                                            fontSize: sp(11),
                                            color: Color(0xFFDE3C31),
                                          ),),
                                        Text(sprintf("  指数 %d赢%d走%d输 %s%s",[
                                          spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),1),
                                          spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),0),
                                          spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),2),
                                          (spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),3)==0? "":(" "+(spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),3).toString()+"大"))),
                                          (spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),4)==0? "":(" "+(spFunGetMatchPanKouCount(spFunGetHistoryList(spProHistoryKey,isPanKou: true),4).toString()+"小"))),

                                        ])
                                          ,style: TextStyle(fontSize: sp(11)),),
                                      ],
                                    ),
                                    SizedBox(height:3),
                                    Row(
                                      children: <Widget>[

                                        spFunGetMatchPanKouRate(spFunGetHistoryList(spProHistoryKey,isPanKou: true),1)==0? SizedBox(): Container(
                                          margin: EdgeInsets.only(right: 2),
                                          alignment: Alignment.center,
                                          width: width(318)*spFunGetMatchPanKouRate(spFunGetHistoryList(spProHistoryKey,isPanKou: true),1),
                                          height: width(4),
                                          color: Color(0xFFDE3C31),
                                        ),
                                        spFunGetMatchPanKouRate(spFunGetHistoryList(spProHistoryKey,isPanKou: true),0)==0? SizedBox(): Container(
                                          margin: EdgeInsets.only(right: 2),
                                          alignment: Alignment.center,
                                          width: width(318)*spFunGetMatchPanKouRate(spFunGetHistoryList(spProHistoryKey,isPanKou: true),0),
                                          height: width(4),
                                          color: Colors.blue,
                                        ),

                                        spFunGetMatchPanKouRate(spFunGetHistoryList(spProHistoryKey,isPanKou: true),2)==0? SizedBox(): Container(
                                          alignment: Alignment.center,
                                          width: width(318)*spFunGetMatchPanKouRate(spFunGetHistoryList(spProHistoryKey,isPanKou: true),2),
                                          height: width(4),
                                          color: Color(0xFF5FB349),
                                        ),

                                      ],
                                    )
                                  ],
                                ),
                              ),
                              matchDetailItem(spFunGetHistoryList(spProHistoryKey),isShowMore: isShowMoreHistory),
                            ],
                        ),
                    )


                  ],

                ),
              ),
              visible:SPClassListUtil.spFunIsNotEmpty(spProHistoryList),
            ),
            ///近期战绩
            Visibility(
              child: Column(
                children: <Widget>[
                  SizedBox(height: width(10),),
                  Row(
                    children: <Widget>[
                      SizedBox(width: width(10),),
                      Container(
                        width: height(4),
                        height: height(14),
                        decoration: BoxDecoration(
                            color: Color(0xFFDE3C31),
                            borderRadius: BorderRadius.circular(100)
                        ),
                      ),
                      SizedBox(width: width(4),),
                      Text("近期战绩",style: TextStyle(fontWeight: FontWeight.w600,fontSize: sp(15)),),
                    ],
                  ),
                  // 主队
                  Container(
                    decoration: BoxDecoration(
                        color: Colors.white,
                        boxShadow:[
                          BoxShadow(
                            offset: Offset(0,0),
                            color: Color(0xFF000000).withOpacity(0.15),
                            blurRadius:width(6,),),
                        ],
                        borderRadius: BorderRadius.circular(4)
                    ),
                    margin: EdgeInsets.only(left: width(10),right: width(10),top: width(10)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          height:width(28),
                          padding: EdgeInsets.only(left: width(14),right: width(10)),
                          decoration: BoxDecoration(
                            color: Color(0xFFF2F2F2),
                            borderRadius: BorderRadius.vertical(top: Radius.circular(4)),
                          ),
                          child: Row(
                            children: <Widget>[
                              Container(
                                child: Row(
                                  children: <Widget>[
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(500),
                                      child:SPClassImageUtil.spFunNetWordImage(
                                          placeholder: "ic_team_one",
                                          url: widget.spProGuessMatch.spProIconUrlOne??'',
                                          width: width(15),
                                          height:  width(15)),
                                    ),
                                    Text("${SPClassStringUtils.spFunMaxLength(widget.spProGuessMatch.spProTeamOne??'',length:4)}",style: TextStyle(color: MyColors.main1,fontSize: sp(11)),),
                                  ],
                                ),
                              ),
                              Expanded(child: SizedBox(),),
//                              全部
                              GestureDetector(
                                onTap:(){
                                  spProHistoryOneKey="全部";
                                  setState(() {
                                  });
                                },
                                child: Row(
                                  children: <Widget>[
                                    Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(spProHistoryOneKey=="全部"?"ic_selected":"ic_select_un",),
                                      width: width(13),
                                    ),
                                    SizedBox(width: width(4),),
                                    Text("全部",style: TextStyle(fontSize: sp(11),color:MyColors.grey_33),)
                                  ],
                                ),
                              ),
                              SizedBox(width: width(10),),
//                              同主客
                              GestureDetector(
                                onTap:(){
                                  spProHistoryOneKey="主场";
                                  setState(() {
                                  });
                                },
                                child: Row(
                                  children: <Widget>[
                                    Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(spProHistoryOneKey=="主场"?"ic_selected":"ic_select_un",),
                                      width: width(13),
                                    ),
                                    SizedBox(width: width(4),),
                                    Text("同主客",style: TextStyle(fontSize: sp(11),color:MyColors.grey_33),)
                                  ],
                                ),
                              ),
                              SizedBox(width: width(14),),
                              // 近10场
                              GestureDetector(
                                onTap:(){
                                  isShowMorejinqiOne=false;
                                  setState(() {

                                  });
                                },
                                child: Container(
                                  height:width(18),
                                  width:width(42),
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.only(
                                          bottomLeft:Radius.circular(width(2)),
                                          topLeft: Radius.circular(width(2))),
                                      border: Border.all(color: !isShowMorejinqiOne? Color(0xFFDE3C31):Color(0xFFC4C4C4),width: 0.4),
                                      color: !isShowMorejinqiOne? Color(0xFFDE3C31):Colors.white
                                  ),
                                  alignment: Alignment.center,
                                  child: Text("近10场",style: TextStyle(fontSize: sp(11),color:!isShowMorejinqiOne?Colors.white:MyColors.main1 ),),
                                ),
                              ),
                              // 近20场
                              GestureDetector(
                                onTap:(){
                                  isShowMorejinqiOne=true;
                                  setState(() {

                                  });
                                },
                                child: Container(
                                  height:width(18),
                                  width:width(42),
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.only(
                                          bottomRight:Radius.circular(width(2)),
                                          topRight: Radius.circular(width(2))),
                                      border: Border.all(color: isShowMorejinqiOne? Color(0xFFDE3C31):Color(0xFFC4C4C4),width: 0.4),
                                      color: isShowMorejinqiOne? Color(0xFFDE3C31):Colors.white
                                  ),
                                  alignment: Alignment.center,
                                  child: Text("近20场",style: TextStyle(fontSize: sp(11),color:isShowMorejinqiOne?Colors.white:MyColors.main1 ),),
                                ),
                              ),
                              GestureDetector(
                                behavior: HitTestBehavior.opaque,
                                child: Container(
                                  padding: EdgeInsets.all(width(7)),
                                  child: Image.asset(SPClassImageUtil.spFunGetImagePath(isShowjinqiOne?"ic_down_arrow":"ic_up_arrow"),
                                    width: width(11),
                                  ),
                                ),
                                onTap: (){
                                  isShowjinqiOne =!isShowjinqiOne;
                                  setState(() {

                                  });
                                },
                              )

                            ],
                          ),
                        ),
                        Visibility(
                          visible: isShowjinqiOne,
                          child: Column(
                            children: <Widget>[
                              SizedBox(height: width(8),),
                              Row(
                                children: <Widget>[
                                  Expanded(
                                    child: Center(
                                      child:  Column(
                                        children: <Widget>[
                                          Stack(
                                            alignment: Alignment.center,
                                            children: <Widget>[
                                              Container(
                                                height: width(64),
                                                width: width(64),
                                                child:SfCircularChart(
                                                  margin: EdgeInsets.zero,
                                                  title: ChartTitle(text: '' ),
                                                  legend: Legend(isVisible: false),
                                                  series: [
                                                    DoughnutSeries<SPClassChartDoughnutData, String>(
                                                      explode: false,
                                                      explodeIndex: 0,
                                                      radius: width(30).toString(),
                                                      innerRadius: width(22).toString(),
                                                      dataSource: [
                                                        SPClassChartDoughnutData(spFunGetMatchCount(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1)*1.0,color: MyColors.main1), //胜
                                                        SPClassChartDoughnutData(spFunGetMatchCount(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 2)*1.0,color: Colors.green), //负
                                                        SPClassChartDoughnutData(spFunGetMatchCount(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 0)*1.0,color: Colors.blue),//走

                                                      ],
                                                      xValueMapper: (SPClassChartDoughnutData data, _) => "",
                                                      yValueMapper: (SPClassChartDoughnutData data, _) => data.percenter,
                                                      pointColorMapper:(SPClassChartDoughnutData data, _) => data.color,
                                                      startAngle: 90,
                                                      endAngle: 90,
                                                    ),
                                                  ],
                                                ),
                                              ),
                                              Text(sprintf("%d胜%d平%s%d负",[
                                                spFunGetMatchCount(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1),
                                                spFunGetMatchCount(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 0),
                                                "\n",
                                                spFunGetMatchCount(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 2),
                                              ]
                                              ),style: TextStyle(fontSize: sp(10),),
                                                textAlign: TextAlign.center,

                                              )
                                            ],
                                          ),
                                          Text(sprintf("近%d场",[getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne).length]),style: TextStyle(fontSize: sp(12),))
                                        ],
                                      ),
                                    ),
                                  ),
                                  Expanded(
                                    child: Center(
                                      child:  Column(
                                        children: <Widget>[
                                          Stack(
                                            alignment: Alignment.center,
                                            children: <Widget>[
                                              Container(
                                                height: width(64),
                                                width: width(64),
                                                child:SfCircularChart(
                                                  margin: EdgeInsets.zero,
                                                  title: ChartTitle(text: '' ),
                                                  legend: Legend(isVisible: false),
                                                  series: [
                                                    DoughnutSeries<SPClassChartDoughnutData, String>(
                                                      explode: false,
                                                      explodeIndex: 0,
                                                      radius: width(30).toString(),
                                                      innerRadius: width(22).toString(),
                                                      dataSource: [
                                                        SPClassChartDoughnutData(spFunGetMatchRate(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1),color: Color(0xFFDE3C31)),
                                                        SPClassChartDoughnutData(1-spFunGetMatchRate(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1),color: Color(0xFEBEBEB)),

                                                      ],
                                                      xValueMapper: (SPClassChartDoughnutData data, _) => "",
                                                      yValueMapper: (SPClassChartDoughnutData data, _) => data.percenter,
                                                      pointColorMapper:(SPClassChartDoughnutData data, _) => data.color,
                                                      startAngle: 90,
                                                      endAngle: 90,
                                                    ),
                                                  ],
                                                ),
                                              ),
                                              Text(sprintf("%s%",[(spFunGetMatchRate(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1)*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(10),))
                                            ],
                                          ),
                                          Text("胜率",style: TextStyle(fontSize: sp(12),))
                                        ],
                                      ),
                                    ),
                                  ),
                                  Expanded(
                                    child: Center(
                                      child:  Column(
                                        children: <Widget>[
                                          Stack(
                                            alignment: Alignment.center,
                                            children: <Widget>[
                                              Container(
                                                height: width(64),
                                                width: width(64),
                                                child:SfCircularChart(
                                                  margin: EdgeInsets.zero,
                                                  title: ChartTitle(text: '' ),
                                                  legend: Legend(isVisible: false),
                                                  series: [
                                                    DoughnutSeries<SPClassChartDoughnutData, String>(
                                                      explode: false,
                                                      explodeIndex: 0,
                                                      radius: width(30).toString(),
                                                      innerRadius: width(22).toString(),
                                                      dataSource: [
                                                        SPClassChartDoughnutData(spFunGetMatchPanKouRate(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1),color: Color(0xFFDE3C31)),
                                                        SPClassChartDoughnutData(1-spFunGetMatchPanKouRate(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1),color: Color(0xFEBEBEB)),

                                                      ],
                                                      xValueMapper: (SPClassChartDoughnutData data, _) => "",
                                                      yValueMapper: (SPClassChartDoughnutData data, _) => data.percenter,
                                                      pointColorMapper:(SPClassChartDoughnutData data, _) => data.color,
                                                      startAngle: 90,
                                                      endAngle: 90,
                                                    ),
                                                  ],
                                                ),
                                              ),
                                              Text(sprintf("%s%",[(spFunGetMatchPanKouRate(getNearData(spFunGetHistoryOneList(spProHistoryOneKey),isShowMorejinqiOne), 1)*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(10),))
                                            ],
                                          ),
                                          Text("赢指率",style: TextStyle(fontSize: sp(12),))
                                        ],
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              SizedBox(height: width(8),),
                              matchDetailItem(spFunGetHistoryOneList(spProHistoryOneKey),isShowMore: isShowMorejinqiOne)
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
                  // 客队
                  Container(
                    decoration: BoxDecoration(
                        color: Colors.white,
                        boxShadow:[
                          BoxShadow(
                            offset: Offset(0,0),
                            color: Color(0xFF000000).withOpacity(0.15),
                            blurRadius:width(6,),),
                        ],
                        borderRadius: BorderRadius.circular(4)
                    ),
                    margin: EdgeInsets.only(left: width(10),right: width(10),top: width(10)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          height:width(28),
                          padding: EdgeInsets.only(left: width(14),right: width(10)),
                          decoration: BoxDecoration(
                            color: Color(0xFFF2F2F2),
                            borderRadius: BorderRadius.vertical(top: Radius.circular(4)),
                          ),
                          child: Row(
                            children: <Widget>[
                              Container(
                                child: Row(
                                  children: <Widget>[
                                    ClipRRect(
                                      borderRadius: BorderRadius.circular(500),
                                      child:SPClassImageUtil.spFunNetWordImage(
                                          placeholder: "ic_team_two",
                                          url: widget.spProGuessMatch.spProIconUrlTwo??'',
                                          width: width(15),
                                          height:  width(15)),
                                    ),
                                    Text("${SPClassStringUtils.spFunMaxLength(widget.spProGuessMatch.spProTeamTwo??'',length:4)}",style: TextStyle(color: MyColors.main1,fontSize: sp(11)),),
                                  ],
                                ),
                              ),
                              Expanded(child: SizedBox(),),
//                              全部
                              GestureDetector(
                                onTap:(){
                                  spProHistoryTwoKey="全部";
                                  setState(() {
                                  });
                                },
                                child: Row(
                                  children: <Widget>[
                                    Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(spProHistoryTwoKey=="全部"?"ic_selected":"ic_select_un",),
                                      width: width(13),
                                    ),
                                    SizedBox(width: width(4),),
                                    Text("全部",style: TextStyle(fontSize: sp(11),color:MyColors.grey_33),)
                                  ],
                                ),
                              ),
                              SizedBox(width: width(10),),
//                              同主客
                              GestureDetector(
                                onTap:(){
                                  spProHistoryTwoKey="主场";
                                  setState(() {
                                  });
                                },
                                child: Row(
                                  children: <Widget>[
                                    Image.asset(
                                      SPClassImageUtil.spFunGetImagePath(spProHistoryTwoKey=="主场"?"ic_selected":"ic_select_un",),
                                      width: width(13),
                                    ),
                                    SizedBox(width: width(4),),
                                    Text("同主客",style: TextStyle(fontSize: sp(11),color:MyColors.grey_33),)
                                  ],
                                ),
                              ),
                              SizedBox(width: width(14),),
                              // 近10场
                              GestureDetector(
                                onTap:(){
                                  isShowMorejinqiTwo=false;
                                  setState(() {

                                  });
                                },
                                child: Container(
                                  height:width(18),
                                  width:width(42),
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.only(
                                          bottomLeft:Radius.circular(width(2)),
                                          topLeft: Radius.circular(width(2))),
                                      border: Border.all(color: !isShowMorejinqiTwo? Color(0xFFDE3C31):Color(0xFFC4C4C4),width: 0.4),
                                      color: !isShowMorejinqiTwo? Color(0xFFDE3C31):Colors.white
                                  ),
                                  alignment: Alignment.center,
                                  child: Text("近10场",style: TextStyle(fontSize: sp(11),color:!isShowMorejinqiTwo?Colors.white:MyColors.main1 ),),
                                ),
                              ),
                              // 近20场
                              GestureDetector(
                                onTap:(){
                                  isShowMorejinqiTwo=true;
                                  setState(() {

                                  });
                                },
                                child: Container(
                                  height:width(18),
                                  width:width(42),
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.only(
                                          bottomRight:Radius.circular(width(2)),
                                          topRight: Radius.circular(width(2))),
                                      border: Border.all(color: isShowMorejinqiTwo? Color(0xFFDE3C31):Color(0xFFC4C4C4),width: 0.4),
                                      color: isShowMorejinqiTwo? Color(0xFFDE3C31):Colors.white
                                  ),
                                  alignment: Alignment.center,
                                  child: Text("近20场",style: TextStyle(fontSize: sp(11),color:isShowMorejinqiTwo?Colors.white:MyColors.main1 ),),
                                ),
                              ),
                              GestureDetector(
                                behavior: HitTestBehavior.opaque,
                                child: Container(
                                  padding: EdgeInsets.all(width(7)),
                                  child: Image.asset(SPClassImageUtil.spFunGetImagePath(isShowjinqiTwo?"ic_down_arrow":"ic_up_arrow"),
                                    width: width(11),
                                  ),
                                ),
                                onTap: (){
                                  isShowjinqiTwo =!isShowjinqiTwo;
                                  setState(() {

                                  });
                                },
                              )

                            ],
                          ),
                        ),
                        Visibility(
                          visible: isShowjinqiTwo,
                          child: Column(
                            children: <Widget>[
                              SizedBox(height: width(8),),
                              Row(
                                children: <Widget>[
                                  Expanded(
                                    child: Center(
                                      child:  Column(
                                        children: <Widget>[
                                          Stack(
                                            alignment: Alignment.center,
                                            children: <Widget>[
                                              Container(
                                                height: width(64),
                                                width: width(64),
                                                child:SfCircularChart(
                                                  margin: EdgeInsets.zero,
                                                  title: ChartTitle(text: '' ),
                                                  legend: Legend(isVisible: false),
                                                  series: [
                                                    DoughnutSeries<SPClassChartDoughnutData, String>(
                                                      explode: false,
                                                      explodeIndex: 0,
                                                      radius: width(30).toString(),
                                                      innerRadius: width(22).toString(),
                                                      dataSource: [
                                                        SPClassChartDoughnutData(spFunGetMatchCount(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo), 1,winTeam: 2)*1.0,color: MyColors.main1), //胜
                                                        SPClassChartDoughnutData(spFunGetMatchCount(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo), 2,winTeam: 2)*1.0,color: Colors.green), //负
                                                        SPClassChartDoughnutData(spFunGetMatchCount(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo), 0,winTeam: 2)*1.0,color: Colors.blue),//走

                                                      ],
                                                      xValueMapper: (SPClassChartDoughnutData data, _) => "",
                                                      yValueMapper: (SPClassChartDoughnutData data, _) => data.percenter,
                                                      pointColorMapper:(SPClassChartDoughnutData data, _) => data.color,
                                                      startAngle: 90,
                                                      endAngle: 90,
                                                    ),
                                                  ],
                                                ),
                                              ),
                                              Text(sprintf("%d胜%d平%s%d负",[
                                                spFunGetMatchCount(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo),1,winTeam: 2),
                                                spFunGetMatchCount(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo),0,winTeam: 2),
                                                "\n",
                                                spFunGetMatchCount(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo),2,winTeam: 2),
                                              ]
                                              ),style: TextStyle(fontSize: sp(10),),
                                                textAlign: TextAlign.center,

                                              )
                                            ],
                                          ),
                                          Text(sprintf("近%d场",[getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo)   .length]),style: TextStyle(fontSize: sp(12),))
                                        ],
                                      ),
                                    ),
                                  ),
                                  Expanded(
                                    child: Center(
                                      child:  Column(
                                        children: <Widget>[
                                          Stack(
                                            alignment: Alignment.center,
                                            children: <Widget>[
                                              Container(
                                                height: width(64),
                                                width: width(64),
                                                child:SfCircularChart(
                                                  margin: EdgeInsets.zero,
                                                  title: ChartTitle(text: '' ),
                                                  legend: Legend(isVisible: false),
                                                  series: [
                                                    DoughnutSeries<SPClassChartDoughnutData, String>(
                                                      explode: false,
                                                      explodeIndex: 0,
                                                      radius: width(30).toString(),
                                                      innerRadius: width(22).toString(),
                                                      dataSource: [
                                                        SPClassChartDoughnutData(spFunGetMatchRate(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo), 1,winTeam: 2),color: Color(0xFFDE3C31)),
                                                        SPClassChartDoughnutData(1-spFunGetMatchRate(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo),1,winTeam: 2),color: Color(0xFEBEBEB)),

                                                      ],
                                                      xValueMapper: (SPClassChartDoughnutData data, _) => "",
                                                      yValueMapper: (SPClassChartDoughnutData data, _) => data.percenter,
                                                      pointColorMapper:(SPClassChartDoughnutData data, _) => data.color,
                                                      startAngle: 90,
                                                      endAngle: 90,
                                                    ),
                                                  ],
                                                ),
                                              ),
                                              Text(sprintf("%s%",[(spFunGetMatchRate(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo),1,winTeam: 2)*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(10),))
                                            ],
                                          ),
                                          Text("胜率",style: TextStyle(fontSize: sp(12),))
                                        ],
                                      ),
                                    ),
                                  ),
                                  Expanded(
                                    child: Center(
                                      child:  Column(
                                        children: <Widget>[
                                          Stack(
                                            alignment: Alignment.center,
                                            children: <Widget>[
                                              Container(
                                                height: width(64),
                                                width: width(64),
                                                child:SfCircularChart(
                                                  margin: EdgeInsets.zero,
                                                  title: ChartTitle(text: '' ),
                                                  legend: Legend(isVisible: false),
                                                  series: [
                                                    DoughnutSeries<SPClassChartDoughnutData, String>(
                                                      explode: false,
                                                      explodeIndex: 0,
                                                      radius: width(30).toString(),
                                                      innerRadius: width(22).toString(),
                                                      dataSource: [
                                                        SPClassChartDoughnutData(spFunGetMatchPanKouRate(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo)   , 1),color: Color(0xFFDE3C31)),
                                                        SPClassChartDoughnutData(1-spFunGetMatchPanKouRate(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo)   , 1),color: Color(0xFEBEBEB)),

                                                      ],
                                                      xValueMapper: (SPClassChartDoughnutData data, _) => "",
                                                      yValueMapper: (SPClassChartDoughnutData data, _) => data.percenter,
                                                      pointColorMapper:(SPClassChartDoughnutData data, _) => data.color,
                                                      startAngle: 90,
                                                      endAngle: 90,
                                                    ),
                                                  ],
                                                ),
                                              ),
                                              Text(sprintf("%s%",[(spFunGetMatchPanKouRate(getNearData(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMorejinqiTwo)   , 1)*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(10),))
                                            ],
                                          ),
                                          Text("赢指率",style: TextStyle(fontSize: sp(12),))
                                        ],
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              SizedBox(height: width(8),),
                              matchDetailItem(spFunGetHistoryTwoList(spProHistoryTwoKey),isShowMore: isShowMorejinqiTwo,team:0)
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),
              visible:!(spProHistoryOne.length==0&&spProHistoryTwo.length==0) ,
            ),
            ///未来赛事
            Visibility(
              child:  Container(
                decoration: BoxDecoration(
                    color: Colors.white,
                    boxShadow:[
                      BoxShadow(
                        offset: Offset(0,0),
                        color: Color(0xFF000000).withOpacity(0.15),
                        blurRadius:width(6,),),
                    ],
                    borderRadius: BorderRadius.circular(4)
                ),                margin: EdgeInsets.only(left: width(10),right: width(10),top: width(10)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      height:width(28),
                      padding: EdgeInsets.only(left: width(14),right: width(10)),
                      decoration: BoxDecoration(
                        color: Color(0xFFF2F2F2),
                        borderRadius: BorderRadius.vertical(top: Radius.circular(4)),
                      ),
                      child: Row(
                        children: <Widget>[
                          Container(
                            width: height(4),
                            height: height(14),
                            decoration: BoxDecoration(
                                color: Color(0xFFDE3C31),
                                borderRadius: BorderRadius.circular(100)
                            ),
                          ),
                          SizedBox(width: 4,),
                          Text("未来赛事",style: TextStyle(fontWeight: FontWeight.w600,fontSize: sp(15)),),
                          Expanded(child: SizedBox(),),
                          GestureDetector(
                            behavior: HitTestBehavior.opaque,
                            child: Container(
                              padding: EdgeInsets.all(width(7)),
                              child: Image.asset(SPClassImageUtil.spFunGetImagePath(isShowFuture?"ic_down_arrow":"ic_up_arrow"),
                                width: width(11),
                              ),
                            ),
                            onTap: (){
                              isShowFuture =!isShowFuture;
                              setState(() {

                              });
                            },
                          )

                        ],
                      ),
                    ),

                    Visibility(
                      visible: isShowFuture,
                      child: AnimatedSize(
                        vsync: this,
                        duration: Duration(
                            milliseconds: 300
                        ),
                        child:Column(
                          children: <Widget>[

                            Visibility(
                              child:Column(
                                children: <Widget>[
                                  Container(
                                    height:width(20),
                                    child: Row(
                                      children: <Widget>[
                                        SizedBox(width: width(10),),
                                        ( widget.spProGuessMatch.spProIconUrlOne!.isEmpty)? Image.asset(
                                          SPClassImageUtil.spFunGetImagePath("ic_team_one"),
                                          width: width(12),
                                        ):Image.network(
                                          widget.spProGuessMatch.spProIconUrlOne??'',
                                          width: width(12),
                                        ),
                                        SizedBox(width: 5,),
                                        Text(widget.spProGuessMatch.spProTeamOne??'',style: TextStyle(fontSize: sp(12)),)
                                      ],

                                    ),
                                  ),
                                  Container(
                                    width: width(360),
                                    decoration: BoxDecoration(
                                        border: Border.all(color: Color(0xFFDDDDDD),width: 0.4)
                                    ),
                                    alignment: Alignment.center,
                                    child: Column(
                                      crossAxisAlignment: CrossAxisAlignment.center,
                                      children: <Widget>[
                                        Container(
                                          height: width(20),
                                          decoration: BoxDecoration(
                                              color: Color(0xFFF7F7F7),
                                              border: Border(bottom:BorderSide(color: Color(0xFFDDDDDD),width: 0.4))
                                          ),
                                          child: Row(
                                            mainAxisAlignment: MainAxisAlignment.center,
                                            children: <Widget>[
                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  child: Text("赛事日期",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,

                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  child: Text("主队",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,

                                              Container(
                                                alignment: Alignment.center,
                                                width: width(30),
                                                child: Text("",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                              ),


                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  child: Text("客队",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,

                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  width: width(40),
                                                  child: Text("间隔",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,


                                            ],
                                          ),
                                        ),

                                        Container(
                                          child: Column(
                                            children: spProFutureListOne.map((item){
                                              return Container(
                                                decoration: BoxDecoration(
                                                    color: Colors.white,
                                                    border: Border(bottom:BorderSide(color: Color(0xFFDDDDDD),width: 0.4))
                                                ),
                                                child: Row(
                                                  mainAxisAlignment: MainAxisAlignment.center,
                                                  children: <Widget>[
                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text(sprintf("%s%s%s",
                                                            [item.spProLeagueName,"\n",SPClassDateUtils.spFunDateFormatByString(item.spProStTime??'', "yyyy.M.dd")]
                                                        ),style: TextStyle(
                                                          fontSize: sp(11),
                                                          color: Color(0xFF666666),
                                                        ),textAlign: TextAlign.center,),
                                                      ),
                                                    ) ,

                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text(item.spProTeamOne??'',style: TextStyle(
                                                          fontSize: sp(11),
                                                          color: spFunGetTeamTextColor(item, 1),
                                                        ),
                                                          maxLines: 1,
                                                          overflow: TextOverflow.ellipsis,
                                                        ),
                                                      ),
                                                    ) ,

                                                    Container(
                                                      alignment: Alignment.center,
                                                      width: width(30),
                                                      child: Text("vs",style: TextStyle(
                                                        fontSize: sp(14),
                                                        color: Color(0xFF888888),
                                                      ),
                                                        maxLines: 1,
                                                        overflow: TextOverflow.ellipsis,
                                                      ),
                                                    ),

                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text(item.spProTeamTwo??'',style: TextStyle(
                                                          fontSize: sp(11),
                                                          color: spFunGetTeamTextColor(item, 2),
                                                        ),
                                                          maxLines: 1,
                                                          overflow: TextOverflow.ellipsis,
                                                        ),
                                                      ),
                                                    ) ,


                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text("${(DateTime.parse(item.spProStTime??'').difference(DateTime.now()).inDays+1).toString()}"+
                                                            "天",style: TextStyle(
                                                          fontSize: sp(11),
                                                        ),textAlign: TextAlign.center,),
                                                      ),
                                                    ) ,


                                                  ],
                                                ),
                                              );
                                            }).toList(),
                                          ),
                                        )

                                      ],
                                    ),
                                  )
                                ],
                              ),
                              visible: SPClassListUtil.spFunIsNotEmpty(spProFutureListOne),
                            ),
                            SizedBox(height: width(10),),
                            Visibility(
                              child:Column(
                                children: <Widget>[
                                  Container(
                                    height:width(20),
                                    child: Row(
                                      children: <Widget>[
                                        SizedBox(width: width(10),),
                                        ( widget.spProGuessMatch.spProIconUrlTwo!.isEmpty)? Image.asset(
                                          SPClassImageUtil.spFunGetImagePath("ic_team_one"),
                                          width: width(12),
                                        ):Image.network(
                                          widget.spProGuessMatch.spProIconUrlTwo??'',
                                          width: width(12),
                                        ),
                                        SizedBox(width: 5,),
                                        Text(widget.spProGuessMatch.spProTeamTwo??'',style: TextStyle(fontSize: sp(12)),)
                                      ],

                                    ),
                                  ),

                                  Container(
                                    width: width(360),
                                    decoration: BoxDecoration(
                                        border: Border.all(color: Color(0xFFDDDDDD),width: 0.4)
                                    ),
                                    alignment: Alignment.center,
                                    child: Column(
                                      crossAxisAlignment: CrossAxisAlignment.center,
                                      children: <Widget>[
                                        Container(
                                          height:width(20),
                                          decoration: BoxDecoration(
                                              color: Color(0xFFF7F7F7),
                                              border: Border(bottom:BorderSide(color: Color(0xFFDDDDDD),width: 0.4))
                                          ),
                                          child: Row(
                                            mainAxisAlignment: MainAxisAlignment.center,
                                            children: <Widget>[
                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  child: Text("赛事日期",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,

                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  child: Text("主队",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,

                                              Container(
                                                alignment: Alignment.center,
                                                width: width(30),
                                                child: Text("",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                              ),


                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  child: Text("客队",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,

                                              Expanded(
                                                child: Container(
                                                  alignment: Alignment.center,
                                                  width: width(40),
                                                  child: Text("间隔",style: TextStyle(fontSize: sp(11),color: Color(0xFF888888)),),
                                                ),
                                              ) ,


                                            ],
                                          ),
                                        ),

                                        Container(
                                          child: Column(
                                            children: spProFutureListTwo.map((item){
                                              return Container(
                                                decoration: BoxDecoration(
                                                    color: Colors.white,
                                                    border: Border(bottom:BorderSide(color: Color(0xFFDDDDDD),width: 0.4))
                                                ),
                                                child: Row(
                                                  mainAxisAlignment: MainAxisAlignment.center,
                                                  children: <Widget>[
                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text(sprintf("%s%s%s",
                                                            [item.spProLeagueName,"\n",SPClassDateUtils.spFunDateFormatByString(item.spProStTime??'', "yyyy.M.dd")]
                                                        ),style: TextStyle(
                                                          fontSize: sp(11),
                                                          color: Color(0xFF666666),
                                                        ),textAlign: TextAlign.center,),
                                                      ),
                                                    ) ,

                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text(item.spProTeamOne??'',style: TextStyle(
                                                          fontSize: sp(11),
                                                          color: spFunGetTeamTextColor(item,1,isOne:false),
                                                        ),
                                                          maxLines: 1,
                                                          overflow: TextOverflow.ellipsis,
                                                        ),
                                                      ),
                                                    ) ,

                                                    Container(
                                                      alignment: Alignment.center,
                                                      width: width(30),
                                                      child: Text("vs",style: TextStyle(
                                                        fontSize: sp(14),
                                                        color: Color(0xFF888888),
                                                      ),
                                                        maxLines: 1,
                                                        overflow: TextOverflow.ellipsis,
                                                      ),
                                                    ),

                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text(item.spProTeamTwo??'',style: TextStyle(
                                                          fontSize: sp(11),
                                                          color: spFunGetTeamTextColor(item,2,isOne:false),
                                                        ),
                                                          maxLines: 1,
                                                          overflow: TextOverflow.ellipsis,
                                                        ),
                                                      ),
                                                    ) ,


                                                    Expanded(
                                                      child: Container(
                                                        alignment: Alignment.center,
                                                        child: Text("${(DateTime.parse(item.spProStTime??'').difference(DateTime.now()).inDays+1).toString()}"+
                                                            "天",style: TextStyle(
                                                          fontSize: sp(11),
                                                        ),textAlign: TextAlign.center,),
                                                      ),
                                                    ) ,


                                                  ],
                                                ),
                                              );
                                            }).toList(),
                                          ),
                                        )

                                      ],
                                    ),
                                  )
                                ],
                              ),
                              visible: SPClassListUtil.spFunIsNotEmpty(spProFutureListTwo),
                            ),

                          ],
                        ) ,
                      ),
                    ),


                  ],

                ),
              ),
              visible:(SPClassListUtil.spFunIsNotEmpty(spProFutureListOne)||SPClassListUtil.spFunIsNotEmpty(spProFutureListTwo)),
            ),


          ],
        ),
      ),
      visible: !spProIsLoading,
      replacement: SPClassLoadingPage(),

    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;



  Widget jifenItem({int team =1}){
    //1主队  0客队
    return Container(
      child:Column(
        children: <Widget>[
          Container(
            height: width(20),
            decoration: BoxDecoration(
              color: Color(0xFFF7F7F7),
              border: Border.symmetric(vertical: BorderSide(width: 0.4,color: Color(0xFFD9D9D9),),)
            ),
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: Text('全场',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('赛',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('胜',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
               widget.type=='篮球'?SizedBox(): Expanded(
                  flex: 1,
                  child: Text('平',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('负',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('得',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('失',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('积分',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('排名',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('胜率',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
              ],
            ),
          ),
          spFunGetTeamPoints('总').isEmpty||(spFunGetTeamPoints('总').length==1&&team==1)?Container():Container(
            height: width(20),
            decoration: BoxDecoration(
                border: Border(bottom: BorderSide(width: 0.2,color: Color(0xFFD9D9D9)))
            ),
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: Text('总',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].spProMatchNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].spProWinNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                widget.type=='篮球'?SizedBox(): Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].spProDrawNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].spProLoseNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].score}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].spProLoseScore}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].points}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('总')[team].ranking}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text(sprintf("%s%",[(double.parse(spFunGetTeamPoints('总')[team].spProWinRate??'0')*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(11),color: MyColors.main1),textAlign: TextAlign.center,),
                ),
              ],
            ),
          ),
          spFunGetTeamPoints('主').isEmpty||(spFunGetTeamPoints('主').length==1&&team==1)?Container():Container(
            height: width(20),
            decoration: BoxDecoration(
                border: Border(bottom: BorderSide(width: 0.2,color: Color(0xFFD9D9D9)))
            ),
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: Text('主',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].spProMatchNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].spProWinNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                widget.type=='篮球'?SizedBox():Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].spProDrawNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].spProLoseNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].score}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].spProLoseScore}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].points}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('主')[team].ranking}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text(sprintf("%s%",[(double.parse(spFunGetTeamPoints('主')[team].spProWinRate??'0')*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(11),color: MyColors.main1),textAlign: TextAlign.center,),
                ),
              ],
            ),
          ),
          spFunGetTeamPoints('客').isEmpty||(spFunGetTeamPoints('客').length==1&&team==1)?Container(): Container(
            height: width(20),
            decoration: BoxDecoration(
                border: Border(bottom: BorderSide(width: 0.2,color: Color(0xFFD9D9D9)))
            ),
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: Text('客',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].spProMatchNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].spProWinNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                widget.type=='篮球'?SizedBox():Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].spProDrawNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].spProLoseNum}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].score}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].spProLoseScore}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].points}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('${spFunGetTeamPoints('客')[team].ranking}',style: TextStyle(fontSize: sp(11),color: MyColors.grey_66),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text(sprintf("%s%",[(double.parse(spFunGetTeamPoints('客')[team].spProWinRate??'0')*100).toStringAsFixed(0)]),style: TextStyle(fontSize: sp(11),color: MyColors.main1),textAlign: TextAlign.center,),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget matchDetailItem(List<SPClassEntityHistory> dataList, {bool isShowMore = false,int team =1}){
    //1主队  0客队
    List<SPClassEntityHistory> list =[];
    if(dataList.isEmpty){
      return Container();
    }
    if(isShowMore){
      list=dataList.length>20?dataList.sublist(0,20).toList():dataList;
    }else{
      list=dataList.length>10?dataList.sublist(0,10).toList():dataList;
    }
    return Container(
      child: Column(
        children: <Widget>[
          Container(
            height: width(20),
            color: Color(0xFFF7F7F7),
            child: Row(
              children: <Widget>[
                SizedBox(width: width(6),),
                Expanded(
                  flex: 2,
                  child: Text('赛事时间',style: TextStyle(fontSize: sp(11),color: MyColors.grey_99),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 2,
                  child: Text('主队',style: TextStyle(fontSize: sp(11),color: MyColors.grey_99),textAlign: TextAlign.right,),
                ),
                Container(
                  width: width(60),
                  child: Text('比分',style: TextStyle(fontSize: sp(11),color: MyColors.grey_99),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 2,
                  child: Text('客队',style: TextStyle(fontSize: sp(11),color: MyColors.grey_99),textAlign: TextAlign.left,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('让球',style: TextStyle(fontSize: sp(11),color: MyColors.grey_99),textAlign: TextAlign.center,),
                ),
                Expanded(
                  flex: 1,
                  child: Text('进球数',style: TextStyle(fontSize: sp(11),color: MyColors.grey_99),textAlign: TextAlign.center,),
                ),
                SizedBox(width: width(6),),

              ],
            ),
          ),
          Container(
            child: Column(
              children: list.map((item) {
                return Container(
                  margin: EdgeInsets.only(bottom: height(4)),
                  child:Row(
                    children: <Widget>[
                      SizedBox(width: width(6),),
                      Expanded(
                        flex: 2,
                        child: Text(sprintf("%s%s%s",
                            [SPClassDateUtils.spFunDateFormatByString(item.spProMatchDate??'', "yyyy.M.dd"),"\n",item.spProLeagueName,]
                        ),style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),textAlign: TextAlign.center,),
                      ),
                      Expanded(
                        flex: 2,
                        child: Text(item.spProTeamOne??'',style: TextStyle(fontSize: sp(11),color: spFunGetTeamTextColor(item,1,isOne: team==1)),textAlign: TextAlign.right,overflow: TextOverflow.ellipsis,),
                      ),
                      Container(
                        width: width(60),
                        child: Text("${item.spProScoreOne} : ${item.spProScoreTwo}",style: TextStyle(fontSize: sp(11),color: MyColors.grey_33),textAlign: TextAlign.center,),
                      ),
                      Expanded(
                        flex: 2,
                        child: Text(item.spProTeamTwo??'',style: TextStyle(fontSize: sp(11),color: spFunGetTeamTextColor(item,2,isOne: team==1)),textAlign: TextAlign.left,overflow: TextOverflow.ellipsis,),
                      ),
                      Expanded(
                        flex: 1,
                        child: Text(item.spProWinOrLose!.isEmpty?"--":sprintf("%s%s%s",
                            [
                              (item.spProAddScore!.isEmpty ? "--":SPClassStringUtils.spFunSqlitZero(item.spProAddScore??'')),
                              "\n",
                              item.spProWinOrLose,
                            ]
                        ),style: TextStyle(fontSize: sp(11),color: spFunGetColorByText(item.spProWinOrLose??''),),textAlign: TextAlign.center,),
                      ),
                      Expanded(
                        flex: 1,
                        child: Text(item.spProBigOrSmall!.isEmpty?"--":sprintf("%s%s%s",
                            [
                              ((item.spProMidScore!.isEmpty||double.tryParse(item.spProMidScore??'0')==0) ? "--":SPClassStringUtils.spFunSqlitZero(item.spProMidScore??'')),
                              "\n",
                              item.spProBigOrSmall,
                            ]
                        ),style: TextStyle(fontSize: sp(11),color: spFunGetColorByText(item.spProBigOrSmall??'')),textAlign: TextAlign.center,),
                      ),
                      SizedBox(width: width(6),),

                    ],
                  ),
                );
              }).toList(),
            ),
          )
        ],
      ),
    );
  }

  List<SPClassEntityHistory> getNearData(List<SPClassEntityHistory> dataList, isShowMore){
    List<SPClassEntityHistory> list =[];
    if(isShowMore){
      list=dataList.length>20?dataList.sublist(0,20).toList():dataList;
    }else{
      list=dataList.length>10?dataList.sublist(0,10).toList():dataList;
    }
    return list;
  }

  spFunGetColorByText(String item) {

    if(item=="赢"||item=="大"){
      return Color(0xFFE3494B);
    }else if(item=="走"){
      return Color(0xFF1C9FB3);
    }else if(item=="小"||item=="输"){
      return Color(0xFF439642);
    }else{
      return Color(0xFF888888);
    }
  }

  spFunGetResultColor(SPClassEntityHistory itemHistory,{int winTeam:1}){

    if(spFunIsHistoryWin(itemHistory,value: winTeam)){
      return Color(0xFFE3494B);
    }else if( spFunIsHistoryDraw(itemHistory)){
      return Colors.blue;
    }else if( spFunIsHistoryLose(itemHistory,value: winTeam)){
      return Color(0xFF439642);
    }else{
      return Color(0xFF333333);
    }

  }

  bool spFunIsHistoryWin(SPClassEntityHistory itemHistory,{int value:1}) {
    int realValue=value;
    if(itemHistory==null||itemHistory.spProScoreOne==null||itemHistory.spProScoreTwo==null){
      return false;
    }

    if(realValue==1){
      if(widget.spProGuessMatch.spProTeamOneId!=null){
        if(widget.spProGuessMatch.spProTeamOneId==itemHistory.spProTeamOneId){
          if(double.parse(itemHistory.spProScoreOne??'0')>double.parse(itemHistory.spProScoreTwo??'0')){
            return true;
          }
        }
        if(widget.spProGuessMatch.spProTeamOneId==itemHistory.spProTeamTwoId){
          if(double.parse(itemHistory.spProScoreTwo??'0')>double.parse(itemHistory.spProScoreOne??'0')){
            return true;
          }
        }

      }


    }

    if(realValue==2){
      if(widget.spProGuessMatch.spProTeamTwoId!=null){
        if(widget.spProGuessMatch.spProTeamTwoId==itemHistory.spProTeamOneId){
          if(double.parse(itemHistory.spProScoreOne??'0')>double.parse(itemHistory.spProScoreTwo??'0')){
            return true;
          }
        }
        if(widget.spProGuessMatch.spProTeamTwoId==itemHistory.spProTeamTwoId){
          if(double.parse(itemHistory.spProScoreTwo??'0')>double.parse(itemHistory.spProScoreOne??'0')){
            return true;
          }
        }
      }
    }

    return false;
  }

  spFunIsHistoryLose(SPClassEntityHistory itemHistory,{int value:1}) {
    int realValue=value;


    if(itemHistory==null||itemHistory.spProScoreOne==null||itemHistory.spProScoreTwo==null){
      return false;
    }

    if(realValue==1){
      if(widget.spProGuessMatch.spProTeamOneId!=null){
        if(widget.spProGuessMatch.spProTeamOneId==itemHistory.spProTeamOneId){
          if(double.parse(itemHistory.spProScoreOne??'0')<double.parse(itemHistory.spProScoreTwo??'0')){
            return true;
          }
        }
        if(widget.spProGuessMatch.spProTeamOneId==itemHistory.spProTeamTwoId){
          if(double.parse(itemHistory.spProScoreTwo??'0')<double.parse(itemHistory.spProScoreOne??'0')){
            return true;
          }
        }

      }


    }

    if(realValue==2){
      if(widget.spProGuessMatch.spProTeamTwoId!=null){
        if(widget.spProGuessMatch.spProTeamTwoId==itemHistory.spProTeamOneId){
          if(double.parse(itemHistory.spProScoreOne??'0')<double.parse(itemHistory.spProScoreTwo??'0')){
            return true;
          }
        }
        if(widget.spProGuessMatch.spProTeamTwoId==itemHistory.spProTeamTwoId){
          if(double.parse(itemHistory.spProScoreTwo??'0')<double.parse(itemHistory.spProScoreOne??'0')){
            return true;
          }
        }
      }
    }

    return false;
  }

  spFunIsHistoryDraw(SPClassEntityHistory itemHistory) {

    if(itemHistory==null||itemHistory.spProScoreOne!.isEmpty||itemHistory.spProScoreTwo!.isEmpty){
      return false;
    }

    if(itemHistory.spProScoreTwo==itemHistory.spProScoreOne){
      return true;
    }

    return false;

  }

  spFunGetHistoryResultText(SPClassEntityHistory itemHistory,{int winTeam:1}) {

    if(itemHistory==null||itemHistory.spProScoreOne!.isEmpty||itemHistory.spProScoreTwo!.isEmpty){
      return "";
    }

    if(itemHistory.spProScoreTwo==itemHistory.spProScoreOne){
      return "平";
    }

    if(spFunIsHistoryWin(itemHistory,value:winTeam )){
      return "胜";
    }else if(spFunIsHistoryLose(itemHistory,value:winTeam )){
      return "负";
    }
    return "";
  }


  List<SPClassEntityHistory>  spFunGetFilterList(List<SPClassEntityHistory> history, int spProHistoryIndex,{String ?value}) {
    String realValue=widget.spProGuessMatch.spProTeamOne??'';

    if(value!=null){
      realValue=value;
    }
    if(spProHistoryIndex==0){
      return history;
    }else{
      List<SPClassEntityHistory> list=[];
      for(var item in history){
        if(realValue==item.spProTeamOne){
          list.add(item);
        }
      }
      return list;
    }
  }

  List<SPClassEntityHistory> spFunGetFilterListNum(List<SPClassEntityHistory> history, int num) {

    if(num==-1){
      return history;
    }else{
      return history.take(num).toList();
    }

  }

  void spFunInitPointData() {
    if(spProAnylizeMatchList!.spProTeamPointsList!=null&&spProAnylizeMatchList!.spProTeamPointsList!.length>0){
      spProTeamPointsList=spProAnylizeMatchList!.spProTeamPointsList!;
    }

  }




  void spFunInitFutureList() {
    if(spProAnylizeMatchList!=null&&(spProAnylizeMatchList!.spProTeamOneFuture!=null&&spProAnylizeMatchList!.spProTeamOneFuture!.length>0)) {
      spProFutureListOne=spProAnylizeMatchList!.spProTeamOneFuture!;
    }
    if(spProAnylizeMatchList!=null&&(spProAnylizeMatchList!.spProTeamTwoFuture!=null&&spProAnylizeMatchList!.spProTeamTwoFuture!.length>0)) {
      spProFutureListTwo=spProAnylizeMatchList!.spProTeamTwoFuture!;
    }
    if(mounted){
      setState(() {});
    }
  }

  List<SPClassTeamPointsList> spFunGetTeamPoints(String spProPointsKey) {
    List<SPClassTeamPointsList> list=[];
    spProTeamPointsList.forEach((item) {
      if(item.type!.contains(spProPointsKey)){
        list.add(item);
      }
    });

    return list;
  }

  List<SPClassEntityHistory> spFunGetHistoryList(String spProHistoryKey,{bool isPanKou:false}) {

    List<SPClassEntityHistory> list=[];
    spProHistoryList.forEach((item) {
      if(isPanKou){

        if(spProHistoryKey=="主场"){
          if(item.spProTeamOne==widget.spProGuessMatch.spProTeamOne){
            if((item.spProWinOrLose!.isNotEmpty))
            {
              list.add(item);
            }
          }
        }else{
          if((item.spProWinOrLose!.isNotEmpty))
          {
            list.add(item);
          }
        }
      }else{
        if(spProHistoryKey=="主场"){
          if(item.spProTeamOne==widget.spProGuessMatch.spProTeamOne){
            list.add(item);
          }
        }else{
          list.add(item);
        }
      }

    });



    return list;
  }

  List<SPClassEntityHistory> spFunGetHistoryOneList(String spProHistoryKey) {

    List<SPClassEntityHistory> list=[];
    spProHistoryOne.forEach((item) {
      if(spProHistoryKey=="主场"){
        if(item.spProTeamOne==widget.spProGuessMatch.spProTeamOne){
          list.add(item);
        }
      }else if (spProHistoryKey=="同主客"){
        if(item.spProTeamOne==widget.spProGuessMatch.spProTeamOne&&item.spProTeamTwo==widget.spProGuessMatch.spProTeamTwo){
          list.add(item);
        }
      }else{
        list.add(item);
      }

    });



    return list;
  }

  List<SPClassEntityHistory> spFunGetHistoryTwoList(String spProHistoryKey) {

    List<SPClassEntityHistory> list=[];
    spProHistoryTwo.forEach((item) {
      if(spProHistoryKey=="主场"){
        if(item.spProTeamOne==widget.spProGuessMatch.spProTeamTwo){
          list.add(item);
        }
      }else if (spProHistoryKey=="同主客"){
        if(item.spProTeamOne==widget.spProGuessMatch.spProTeamOne&&item.spProTeamTwo==widget.spProGuessMatch.spProTeamTwo){
          list.add(item);
        }
      }else if (spProHistoryKey=="客场"){
        if(item.spProTeamTwo==widget.spProGuessMatch.spProTeamTwo){
          list.add(item);
        }
      }else{
        list.add(item);
      }

    });



    return list;
  }

  //value 1 =win ; 2=lose;
  double spFunGetMatchPanKouRate(List<SPClassEntityHistory> valueList,value) {
    var valueCount=0.0;
    valueList.forEach((item) {
      if(value==1&&item.spProWinOrLose=="赢"){
        valueCount+=1;
      }
      if(value==2&&item.spProWinOrLose=="输"){
        valueCount+=1;
      }
      if(value==0&&item.spProWinOrLose=="走"){
        valueCount+=1;
      }

    });
    if(valueCount==0){
      return 0;
    }

    return valueCount/valueList.length;
  }

  //value 1 =win ; 2=lose; 0=draw;
  double spFunGetMatchRate(List<SPClassEntityHistory> valueList,value,{int winTeam:1}) {
    var valueCount=0.0;
    valueList.forEach((item) {
      if(value==1&&spFunIsHistoryWin(item,value: winTeam)){
        valueCount+=1;
      }
      if(value==2&&spFunIsHistoryLose(item,value: winTeam)){
        valueCount+=1;
      }
      if(value==0&&spFunIsHistoryDraw(item)){
        valueCount+=1;
      }

    });
    if(valueCount==0){
      return 0;
    }

    return valueCount/valueList.length;
  }

  //value 1 =win ; 2=lose; 0=draw;

  int spFunGetMatchCount(List<SPClassEntityHistory> valueList,value,{int winTeam:1}) {
    var valueCount=0;
    valueList.forEach((item) {
      if(value==1&&spFunIsHistoryWin(item,value: winTeam)){
        valueCount+=1;
      }
      if(value==2&&spFunIsHistoryLose(item,value: winTeam)){
        valueCount+=1;
      }
      if(value==0&&spFunIsHistoryDraw(item)){
        valueCount+=1;
      }

    });


    return valueCount;
  }


  //value 1 =win ; 2=lose; 0=draw;

  int spFunGetMatchPanKouCount(List<SPClassEntityHistory> valueList,value,{int winTeam:1}) {
    var valueCount=0;
    valueList.forEach((item) {
      if(value==1&&item.spProWinOrLose=="赢"){
        valueCount+=1;
      }
      if(value==2&&item.spProWinOrLose=="输"){
        valueCount+=1;
      }
      if(value==0&&item.spProWinOrLose=="走"){
        valueCount+=1;
      }
      if(value==3&&item.spProBigOrSmall=="大"){
        valueCount+=1;
      }
      if(value==4&&item.spProBigOrSmall=="小"){
        valueCount+=1;
      }
    });


    return valueCount;
  }

  double spFunGetMatchAllPointsScore(int team,key) {
    var result=0.0;
    var one=0;
    var two=0;

    one= (spFunGetMatchCount(spFunGetHistoryOneList(key).take(spFunGetMinListLength(key)).toList(), 1)*3)+(spFunGetMatchCount(spFunGetHistoryOneList(key).take(spFunGetMinListLength(key)).toList(), 0)*1);
    two= (spFunGetMatchCount(spFunGetHistoryTwoList(key).take(spFunGetMinListLength(key)).toList(), 1,winTeam: 2)*3)+
        (spFunGetMatchCount(spFunGetHistoryTwoList(key).take(spFunGetMinListLength(key)).toList(), 0,winTeam: 2)*1);



    if(team==1&&one==0){
      return 0;
    }
    if(team==2&&two==0){
      return 0;
    }

    if(team==1){
      result=  one/(one+two)*25;
    }
    if(team==2){
      result= two/(one+two)*25;
    }

    return result;
  }

  double spFunAvgWinOrLoseScoreOne(bool spProIsWin){
    var result=0.0;
    var winCount=0;
    var loseCount=0;


    spFunGetHistoryOneList("全部").take(spFunGetMinListLength("全部")).toList().forEach((item) {

      if(item.spProTeamOne==widget.spProGuessMatch.spProTeamOne){
        winCount+=int.parse(item.spProScoreOne??'0');
      }
      if(item.spProTeamTwo==widget.spProGuessMatch.spProTeamOne){
        winCount+=int.parse(item.spProScoreTwo??'0');
      }

      if(item.spProTeamOne!=widget.spProGuessMatch.spProTeamOne){
        loseCount+=int.parse(item.spProScoreOne??'0');
      }
      if(item.spProTeamTwo!=widget.spProGuessMatch.spProTeamOne){
        loseCount+=int.parse(item.spProScoreTwo??'0');
      }

    });
    if(spProIsWin&&winCount==0){
      return 0;
    }
    if(!spProIsWin&&loseCount==0){
      return 0;
    }

    if(spProIsWin){
      result=  winCount/spFunGetHistoryOneList("全部").take(spFunGetMinListLength("全部")).toList().length;
    }
    if(!spProIsWin){
      result= loseCount/spFunGetHistoryOneList("全部").take(spFunGetMinListLength("全部")).toList().length;
    }


    return result;
  }
  double spFunAvgWinOrLoseScoreTwo(bool spProIsWin){
    var result=0.0;
    var winCount=0;
    var loseCount=0;


    spFunGetHistoryTwoList("全部").take(spFunGetMinListLength("全部")).toList().forEach((item) {
      if(item.spProTeamOne==widget.spProGuessMatch.spProTeamTwo){
        winCount+=int.parse(item.spProScoreOne??'0');
      }
      if(item.spProTeamTwo==widget.spProGuessMatch.spProTeamTwo){
        winCount+=int.parse(item.spProScoreTwo??'0');
      }

      if(item.spProTeamOne!=widget.spProGuessMatch.spProTeamTwo){
        loseCount+=int.parse(item.spProScoreOne??'0');
      }
      if(item.spProTeamTwo!=widget.spProGuessMatch.spProTeamTwo){
        loseCount+=int.parse(item.spProScoreTwo??'0');
      }
    });


    if(spProIsWin&&winCount==0){
      return 0;
    }
    if(!spProIsWin&&loseCount==0){
      return 0;
    }

    if(spProIsWin){
      result=  winCount/spFunGetHistoryTwoList("全部").take(spFunGetMinListLength("全部")).toList().length ;
    }
    if(!spProIsWin){
      result= loseCount/spFunGetHistoryTwoList("全部").take(spFunGetMinListLength("全部")).toList().length ;
    }


    return result;
  }

  double spFunAvgWinOrLose25Score(bool spProIsWin,int team ){
    var result =0.0;
    var value=0.0;

    if(team==1){
      value=(spFunAvgWinOrLoseScoreOne(spProIsWin));
    }else{
      value=(spFunAvgWinOrLoseScoreTwo(spProIsWin));
    }

    if(value==0){
      return 0;
    }

    result= (value/(spFunAvgWinOrLoseScoreOne(spProIsWin)+ spFunAvgWinOrLoseScoreTwo(spProIsWin))*25);


    return result;
  }

  int spFunGetMinListLength(String key){

    return min(spFunGetHistoryOneList(key).take(10).toList().length, spFunGetHistoryTwoList(key).take(10).toList().length);
  }

  // Color spFunGetTeamTextColor(SPClassEntityHistory team, int i,{bool isOne:true}) {
  //
  //     if(isOne){
  //       if(i==1&&(team.spProTeamOne==widget.spProGuessMatch.spProTeamOne||widget.spProGuessMatch.spProTeamOneId==team.spProTeamOneId)){
  //         return Color(0xFF333333);
  //       }
  //
  //       if(i==2&&(team.spProTeamTwo==widget.spProGuessMatch.spProTeamOne||widget.spProGuessMatch.spProTeamOneId==team.spProTeamTwoId)){
  //         return Color(0xFF333333);
  //       }
  //     }
  //     if(!isOne){
  //       if(i==1&&(team.spProTeamOne==widget.spProGuessMatch.spProTeamTwo||widget.spProGuessMatch.spProTeamTwoId==team.spProTeamOneId)){
  //         return Color(0xFF333333);
  //       }
  //
  //       if(i==2&&(team.spProTeamTwo==widget.spProGuessMatch.spProTeamTwo||widget.spProGuessMatch.spProTeamTwoId==team.spProTeamTwoId)){
  //         return Color(0xFF333333);
  //       }
  //     }
  //
  //    return Color(0xFF888888);
  //
  // }

  double spFunGetForecastHeight( int i) {

    if(spProForecastInfo!=null){
      if(i==1){
        return double.tryParse(spProForecastInfo?.spProWinPOne??'0')!*width(50);
      }
      if(i==0){
        return double.tryParse(spProForecastInfo?.spProDrawP??'0')!*width(50);
      }
      if(i==2){
        return double.tryParse(spProForecastInfo?.spProWinPTwo??'0')!*width(50);
      }
    }
    return 0.0;
  }

  double  spFunGetUserSupport(int i) {

    if(spProForecastInfo!=null){
      var supportOne=double.tryParse(spProForecastInfo?.spProSupportOneNum??'0');
      var supportTwo=double.tryParse(spProForecastInfo?.spProSupportTwoNum??'0');
      var supportDraw=double.tryParse(spProForecastInfo?.spProSupportDrawNum??'0');
      double allNum=(supportOne!+supportTwo!+supportDraw!);
      if(allNum==0){
        return 0;
      }
      if(i==1){
        return (supportOne/allNum)*0.5;
      }
      if(i==0){
        return (supportDraw/allNum)*0.5;
      }
      if(i==0){
        return (supportTwo/allNum)*0.5;
      }
    }
    return 0.0;
  }

  String spFunGetSupportRate(int i) {

    if(spProForecastInfo!=null){

      if(i==1){
        return (double.tryParse(spProForecastInfo?.spProWinPOne??'0')!*100).toStringAsFixed(0)+"%";
      }
      if(i==0){
        return (double.tryParse(spProForecastInfo?.spProDrawP??'0')!*100).toStringAsFixed(0)+"%";
      }
      if(i==2){
        return (double.tryParse(spProForecastInfo?.spProWinPTwo??'0')!*100).toStringAsFixed(0)+"%";
      }
    }
    return "";
  }

  void spFunGetForecastInfo() {
    Api.spFunMatchForecast<SPClassForecast>(
        queryParameters: {"guess_match_id":widget.spProGuessMatch.spProGuessMatchId},
        spProCallBack: SPClassHttpCallBack(
            spProOnSuccess: (result){
              if(result.spProWinPTwo!=null){
                spProForecastInfo=result;
                setState(() {});
              }

            }
        )
    );
  }

  void spFunSupportForecast(String witch) {
    if(spFunIsLogin(context: context)){
      Api.spFunForecastAdd<SPClassBaseModelEntity>(
          queryParameters:{
            "guess_match_id":widget.spProGuessMatch.spProGuessMatchId,
            "support_which":witch,
          },
          spProCallBack: SPClassHttpCallBack(
              spProOnSuccess: (result){
                spFunGetForecastInfo();
              }
          ));
    }
  }

  Color spFunGetTeamTextColor(SPClassEntityHistory team, int i,
      {bool isOne: true}) {
    if (isOne) {
      // 主队在主场
      if (i == 1 &&
          (team.spProTeamOne == widget.spProGuessMatch.spProTeamOne ||
              widget.spProGuessMatch.spProTeamOneId == team.spProTeamOneId)) {
        if(spFunIsHistoryWin(team, value: 1)){
          return Colors.red;
        }else if(spFunIsHistoryLose(team, value: 1)){
          return Colors.green;
        }
      }
      // 主队在客场
      if (i == 2 &&
          (team.spProTeamTwo == widget.spProGuessMatch.spProTeamOne ||
              widget.spProGuessMatch.spProTeamOneId == team.spProTeamTwoId)) {
        if(spFunIsHistoryWin(team, value: 1)){
          return Colors.red;
        }else if(spFunIsHistoryLose(team, value: 1)){
          return Colors.green;
        }
        // return Colors.deepPurpleAccent;
      }
    }

    // 客队
    if (!isOne) {
      // 客队在主场
      if (i == 1 &&
          (team.spProTeamOne == widget.spProGuessMatch.spProTeamTwo ||
              widget.spProGuessMatch.spProTeamTwoId == team.spProTeamOneId)) {
        if(spFunIsHistoryWin(team, value: 2)){
          return Colors.red;
        }else if(spFunIsHistoryLose(team, value: 2)){
          return Colors.green;
        }
      }

      if (i == 2 &&
          (team.spProTeamTwo == widget.spProGuessMatch.spProTeamTwo ||
              widget.spProGuessMatch.spProTeamTwoId == team.spProTeamTwoId)) {
        if(spFunIsHistoryWin(team, value: 2)){
          return Colors.red;
        }else if(spFunIsHistoryLose(team, value: 2)){
          return Colors.green;
        }
      }
    }

    return MyColors.grey_33;
  }
}